package org.shop.pro.config.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.shop.pro.entity.Bossinfo;
import org.shop.pro.entity.User;
import org.shop.pro.mapper.UserMapper;
import org.shop.pro.service.BossinfoService;
import org.shop.pro.service.UserMapperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class UserController {
	@Autowired
	UserMapperService userMapperService;
	@Autowired
	BossinfoService bossinfoService;
	/**
	 * 
	    * @Title: index
	    * @Description: TODO(这里用一句话描述这个方法的作用)
	    * @param @param username
	    * @param @param password
	    * @param @param model
	    * @param @param session
	    * @param @return    参数
	    * @return String    返回类型
	    * @throws
	 */

	@RequestMapping("/index")
	public String index(String username,Integer password,Model model,HttpSession session) {
		User user= userMapperService.userLogin(username, password);
		if(user==null){
			
			
			return "redirect:login";
		}
		session.setAttribute("user", user);
		if(user.getShop()==1){
			Bossinfo bossinfo=bossinfoService.selectshopid(user.getId());
			session.setAttribute("bossinfo", bossinfo);
			return "shop/index";
		}
		return "index";

	}
	/***
	 * 
	    * @Title: index_shouye
	    * @Description: TODO(这里用一句话描述这个方法的作用)
	    * @param @param s
	    * @param @return    参数
	    * @return String    返回类型
	    * @throws
	 */
	@RequestMapping("/shouye")
	public String indexshouye(Model s) {
		
		return "shouye";

	}
	/***
	 * 
	    * @Title: test
	    * @Description: TODO(用户登录)
	    * @param @param model
	    * @param @return    参数
	    * @return String    返回类型
	    * @throws
	 */
	@RequestMapping("/login")
	public String test(Model model) {
		
		
		return "login";
	}
	@RequestMapping("/shop/shouye")
	public String indexshopshouye(Model s) {
		
		return "shop/shouye";

	}
}
